//package com.plian.system.service.yth.impl;
//
//import com.baomidou.dynamic.datasource.annotation.DS;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.entity.dj.DjPartyBrandInfo;
//import com.plian.system.entity.yth.dj.PartyBrandMap;
//import com.plian.system.mapper.yth.dj.PartyBrandMapMapper;
//import com.plian.system.service.yth.IPartyBrandMapService;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Propagation;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.*;
//
///**
// * @Description:
// * @Author: jatpen
// * @Date: 2023/4/19 9:50 AM
// */
//@Slf4j
//@Service
//@DS("slave_1")
//public class PartyBrandMapServiceImpl extends ServiceImpl<PartyBrandMapMapper, PartyBrandMap> implements IPartyBrandMapService {
//
//    private final String YTH_DATASOURCE_TYPE = "3";
//
//    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
//    @DS("slave_1")
//    @Override
//    public List<DjPartyBrandInfo> getSyncData(Date startTime, Date endTime) {
//        List<DjPartyBrandInfo> djPartyBrandInfos = new ArrayList<>();
//        List<PartyBrandMap> partyBrandMaps = list(new LambdaQueryWrapper<PartyBrandMap>()
//                .gt(Optional.ofNullable(startTime).isPresent(), PartyBrandMap::getCreateTime, startTime)
//                .le(Optional.ofNullable(endTime).isPresent(), PartyBrandMap::getCreateTime, endTime)
//        );
//        if (CollectionUtil.isNotEmpty(partyBrandMaps)) {
//            djPartyBrandInfos = conversion(partyBrandMaps);
//        }
//        return djPartyBrandInfos;
//    }
//
//    /**
//     * 转换党建对象
//     *
//     * @param partyBrandMaps
//     * @return
//     */
//    private List<DjPartyBrandInfo> conversion(List<PartyBrandMap> partyBrandMaps) {
//
//        List<DjPartyBrandInfo> djPartyBrandInfoList = new ArrayList<>();
//        for (PartyBrandMap partyBrandMap : partyBrandMaps) {
//            DjPartyBrandInfo djPartyBrandInfo = new DjPartyBrandInfo();
//            djPartyBrandInfo.setPartyBranchName(partyBrandMap.getPartyBranchOrganization());
//            djPartyBrandInfo.setUnitOwnershipId(Objects.toString(partyBrandMap.getUnitId(),null));
//            djPartyBrandInfo.setUnitOwnershipName(partyBrandMap.getUnitName());
//            djPartyBrandInfo.setContact(partyBrandMap.getPhone());
//           // djPartyBrandInfo.setPartyBrandNum();//党建品牌图数量
//            djPartyBrandInfo.setPartyPerformance(partyBrandMap.getWorkEffect());
//            djPartyBrandInfo.setDataSource(YTH_DATASOURCE_TYPE);
//            djPartyBrandInfo.setDataSourceId(partyBrandMap.getId().toString());
//            djPartyBrandInfoList.add(djPartyBrandInfo);
//        }
//        return djPartyBrandInfoList;
//    }
//}
